package com.scy.hospitalmanager.until;

import com.scy.hospitalmanager.pojo.Patient;

import java.util.Random;

/**
 * @Description:
 * @ClassName: PatientUtil
 * @Author: KuonnjiArisu
 * @Date: 2021/9/24 17:18
 * @Version: 1.0
 */
public class PatientUtil {
    public static String getRandomPatient(){
        Random random = new Random();
        Patient patient = new Patient();
        String date="";
        String str ="";
        String condition = "";
        for (int j = 0; j < 3; j++) {
            str+= "j";
            condition+="j";
        }
        String randomNumber =" ";
        for(int a = 0;a<7;a++){
            randomNumber+=String.valueOf(random.nextInt(9)+1);
            int x = random.nextInt(9)+1;
            int y = random.nextInt(2)+1;
            int z = random.nextInt(3)+1;
            if (a==3){
                date+=String.valueOf(x)+"-";
            }
            else if (a==5){
                date = date+String.valueOf(y)+"-";
            }else {
                date += String.valueOf(z);
            }
        }
        String sql1 ="INSERT INTO `hospital`.`nms_patient_patients`(`pa_name`, `pa_age`, `pa_sex`, `pa_evaluation_grade`, `pa_nursing_grade`, `pa_department_id`, `pa_number`, `pa_main_condition`, `pa_admission_date`) VALUES (";
        patient.setPaName(str);
        patient.setPaAge(random.nextInt(61)+20);
        patient.setPaSex(random.nextInt(2));
        int m = random.nextInt(3)+1;
        int n =random.nextInt(4)+1;
        patient.setPaEvaluationGrade(String.valueOf(m));
        patient.setPaNursingGrade(String.valueOf(n));
        patient.setPaDepartmentId(m);
        patient.setPaMainCondition(condition);
        patient.setPaNumber(randomNumber);
        patient.setPaAdmissionDate(date);
        String sql2 = "'"+patient.getPaName()+"'"+","+"'"+patient.getPaAge()+"'"+","+"'"+ patient.getPaSex()+"'"+","+ "'"+patient.getPaEvaluationGrade()+"'"+","+"'"+patient.getPaNursingGrade()+"'"+","+"'"+ patient.getPaDepartmentId()+"'"+","+"'"+patient.getPaNumber() +"'"+","+"'"+patient.getPaMainCondition()+"'"+","+ "'"+patient.getPaAdmissionDate()+"'"+")"+";";
        String sumSql = sql1+sql2;
        String temp = "INSERT INTO `nms_patient_patients` VALUES (6, '阮立诚', 78, 1, '3', '3', 2, '2019045', '脑震荡', '2021-8-7', NULL, 11);"+"\n";
        String simpleSql  = sql1+temp;
        System.out.println(sumSql);
        return sumSql;
    }

}
